<template>
	<view>
		<view class="InfoBOX">
			<view class="Title">请设置您的登录密码</view>
			<view class="linhe"><text class="red">*</text>设置新密码</view>
			<view class="Code">
				<input maxlength="20" type="password" v-model="password" placeholder="8-20位字符，由英文、数字及标点符号组成"/>
			</view>
			<view class="linhe"><text class="red">*</text>确认新密码</view>
			<view class="Code">
				<input maxlength="20"  type="password" v-model="confirm_password" placeholder="请再次输入您设置的密码"/>
			</view>
			<view class="Next" @click="Submission">
				提交
			</view>
		</view>
		
	</view>
</template>

<script>
	const msdjs = require('../../common/api_sign/md5.js');
	export default {
		data() {
			return {
				password:"",
				confirm_password:"",
				auth_modify_paypwd:"",
			}
		},
		created() {
		},
		methods: {
		
			Submission(){
				let that = this;
				var reg = /^(?=.*[A-Za-z])(?=.*\d)(?=.*[`~!@#$%^&*()_+<>?:"{},.\/\\;'[\]])[A-Za-z\d`~!@#$%^&*()_+<>?:"{},.\/\\;'[\]]{8,}$/ ;
				console.log(!reg.test(that.password));
				 if(that.password.length<6||that.password.length>20){
				       uni.showToast({
				       	title:"请设置8-20位密码",
				       	icon:"none"
				       })
					   return false;
				  }
				if(!reg.test(that.password)){
					uni.showToast({
						title:"请设置英文+字符+数字密码",
						icon:"none"
					})
					return false;
				}
				if(!that.password || !that.confirm_password){
					uni.showToast({
						icon:"none",
						title:"请输入新密码"
					})
				}else if(that.password != that.confirm_password){
					uni.showToast({
						icon:"none",
						title:"两次输入密码不一致"
					})
				}else{
					this.$util.request({
						url: '/mobile/index.php?act=member_security&op=modify_pwd',
						method: 'POST',
						data: {
							auth_modify_paypwd:that.auth_modify_paypwd,
							password:msdjs.hexMD5(that.password),
							confirm_password:msdjs.hexMD5(that.confirm_password)
						},
					}).then(function(res) {
						console.log(res)
						if(res.error_code==0){
							uni.showToast({
								title:"保存成功",
								success() {
									setTimeout(()=>{
										// uni.reLaunch({
										// 	url:"/pagesB/bages/newpage/zhanghuaq"
										// })
										uni.switchTab({
											url:"/main/member/index"
										})
									},1000)
								}
							})
						}else{
							uni.showToast({
								title:res.message,
								icon:"none"
							})
						}
					})
				}
				
			}
		},
		onLoad(e){
			this.auth_modify_paypwd=e.auth_modify_paypwd
		},
		
	}
</script>

<style>
	.red{
		color: red;
	}
	.InfoBOX{
		margin: 20rpx;
		padding: 15rpx 40rpx;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		}
	.Title{
		font-size: 32rpx;
		text-align: center;
	}
	.linhe{
		line-height: 70rpx;
	}
	.Code{
		width: 100%;
		height: 70rpx;
		border: 1rpx solid #eee;
		margin: 10rpx 0;
	}
	.Code input{
		height: 70rpx;
		margin-left: 15rpx;
		font-size: 28rpx;
	}
	.Next{
		background-color: #ff4300;
		color: #FFFFFF;
		font-size: 30rpx;
		line-height: 70rpx;
		margin: 25rpx 0;
		text-align: center;
	}
</style>
